'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    // 配置proxy跨域请求代理 作用是用来，建一个虚拟api服务器用来代理本机的请求，只能用于开发模式 
    proxyTable: {
      // url中匹配到 '/api' 就会吧url中 '/api' 之前的东西全部替换为下面target中的东西
      // '/api': {
      //   target: 'http://172.20.1.139:8080',  //目标接口域名
      //   changeOrigin: true,  //是否跨域
      //   // secure: false,  // 如果是https接口，需要配置这个参数
      //   // pathRewrite: {
      //   //   '^/api': '/'   //重写接口
      //   // }
      // }
    },

    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8888, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    // Use Eslint Loader?
    // If true, your code will be linted during bundling and
    // linting errors and warnings will be shown in the console.
    useEslint: true,
    // If true, eslint errors and warnings will also be shown in the error overlay
    // in the browser.
    showEslintErrorsInOverlay: false,

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'), //  代表打包后，index.html文件的位置

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'), // 在当前目录的上一级 的 dist目录下输出资源文件
    assetsSubDirectory: 'static', // 把所有的静态资源打包到 dist下的 static文件夹下
    assetsPublicPath: '/', //  代表打包后，index.html里面引用资源的的相对地址

    /**
     * Source Maps
     */

    productionSourceMap: true, // 定义是否生成生产环境的sourcmap，sourcmap是用来debug编译后文件的，通过映射到编译前文件来实现
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false, // 是否在生产环境中压缩代码，如果要压缩必须安装compression-webpack-plugin
    productionGzipExtensions: ['js', 'css'], // 定义要压缩哪些类型的文件

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    // 下面是用来开启编译完成后的报告，可以通过设置值为true和false来开启或关闭 
    // 下面的process.env.npm_config_report表示定义的一个npm_config_report环境变量，可以自行设置
    bundleAnalyzerReport: process.env.npm_config_report
  }
}
